home *** CD-ROM | disk | FTP | other *** search
/ Shareworld 5 / Shareworld 5 (Disk 1 of 2).adf / OpenWindow / OpenWindow.Example2 < prev    next >
Text File  |  1995-08-29  |  3KB  |  87 lines

  1.     ;Open window, public domain
  2.     ;Published with Share-world 5
  3.     ;This version is coded differently with respect to closing the
  4.     ;library and window. It is based on the first in last out method.
  5.     ;This is neater than the 'check if pointer zero' method but can cause
  6.     ;problems when adding new 'openings' latter (eg opening another library)
  7.  
  8.     ;-- Exec --
  9. Openlib        = -552
  10. Closelib    = -414
  11.  
  12.     ;-- Intuition --
  13. Openwindow    =    -204    
  14. Closewindow    =    -72
  15.  
  16.     ;Program
  17. Start
  18.     move.l 4,a6    ;Get exec lib base
  19.     move.l #iname,a1    ;library name
  20.     move.l #0,d0    ;any version
  21.     jsr Openlib(a6)    ;open
  22.     cmp.l #0,d0    ;d0 will be zero if lib no open
  23.     beq noibase    ;check for error, if error go to error
  24.     move.l d0,ibase    ;store base
  25.     move.l ibase,a6    ;could change to move.l d0,a6
  26.  
  27.     move.l #Window,a0    ;a0 now holds a pointer to the Window 
  28.                 ;Definition Table
  29.     jsr Openwindow(a6)
  30.  
  31.     cmp.l #0,d0    ;D0 will be zero if the window has failed to open
  32.     beq nowindow    ;Did it open?
  33.     move.l d0,windowhd    ;Store that handle
  34.  
  35.     bsr delay    ;Branch to the delay subroutine
  36.             ;Delays can also be created by using any of 
  37.             ;Auckland's public transport
  38.  
  39.     ;The following closing must be done is the opposite order to 
  40.     ;how they were opened
  41.  
  42.     move.l ibase,a6        ;It's that ibase character again!
  43.     move.l windowhd,a0    ;Get handle of window (so computer nos what
  44.                 ;window to close)
  45.     jsr Closewindow(a6)    ;Closing due to renovations
  46. nowindow    
  47.     move.l 4,a6    ;get exec base
  48.     move.l ibase,a1    ;library base for closing
  49.     jsr Closelib(a6)    ;Let's close this thing once and for all
  50. noibase
  51.     moveq #0,d0    ;Extra bit not mention in article, tell Cli no 
  52.             ;error, 0 okay, 20 failure
  53.     rts        ;exit to CLI, or assembler
  54. delay
  55.     move.l #0,d0        ;clear d0 (start counting from zero)
  56. dl1
  57.     add.l #1,d0    
  58.     cmp.l #3000000,d0    ;lasts for about 2-3 secs of my A1200
  59.     bne dl1            ;Are we there yet?
  60.     rts            ;Yes!
  61.     
  62.     ;variables
  63. ibase    dc.l 0            ;storage for ibase
  64. windowhd    dc.l 0        ;storage for window's handle
  65.     
  66.     ;Window Definition
  67. Window
  68.     dc.w 10,30    ;x-y position
  69.     dc.w 200,200    ;width-height
  70.     dc.b 1,2    ;colours
  71.     dc.l $200    ;'flags' for messages (next issue!)
  72.     dc.l $100f    ;'flags' for appareance (next issue!!)
  73.             ;Change to $1800 for no border!
  74.     dc.l 0,0    ;gadgets, checkmark
  75.     dc.l WinName    ;pointer to window name
  76.     dc.l 0        ;screen pointer (don't matter/using workbench)
  77.     dc.l 0         ;No bitmap (for fancy windows only!)
  78.     dc.w 100,100    ;smallest width-height
  79.     dc.w 600,250    ;largest width-height
  80.     dc.w 1        ;workbench window
  81.  
  82.     ;strings
  83. iname    dc.b 'intuition.library',0
  84. WinName
  85.     dc.b 'My Window likes U2',0    ;Do you?
  86.     
  87.